<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/base/taglibs.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>${systemOption.systemTitle}</title>
    <%@ include file="/base/head.jsp"%>
    <script type="text/javascript" charset="UTF-8">
    
        	//增加
  	function add_xx(){
  		$('#baseAddWnd').show();
            $('#baseAddWnd').dialog({
            	iconCls:'icon-user-add',
            	title:'增加信息',
            	modal:true,
            	buttons: [{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					$('#baseAddForm').form('submit',{  
					    success: function(data){   
					        if(data=='01'){  
					            $.messager.alert('友情提示','增加成功','info'); 
					            resetDG('#baseList'); 
					        }else{
					        	$.messager.alert('友情提示','增加失败','error'); 
					        } 
					        $('#baseAddWnd').dialog('close');
					    }  
					});
				}
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#baseAddWnd').dialog('close');
				}
		}]
            });                
  		$('#baseAddForm').form('reset');
  		$('#baseName').focus();  
  	}
  //修改
  function edit_xx(){
  	var row = $('#baseList').datagrid('getSelected');
	if (!row){
		$.messager.alert('友情提示','请选择信息','error');
	}else{
		$('#updateWnd').show();
		$('#updateWnd').dialog({
        iconCls:'icon-edit',
        title:'修改信息',
        modal:true,
        buttons:[{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					$('#updateFrom').form('submit',{
					    success: function(data){
					        if(data=='01'){
					            $.messager.alert('友情提示','修改成功','info');
					            resetDG('#baseList');
					        }else{
					        	$.messager.alert('友情提示','修改失败','error');
					        }
					        $('#updateWnd').dialog('close');
					    }
					});
				}
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#updateWnd').dialog('close');
				}
		}]
            });
         console.log(row);
 		$('#baseId2').val(row.id);
 		$('#baseuId2').val(row.uid);
 		$('#baseempId2').val(row.empid);
 		$('#baseName2').textbox('setValue',row.dtruename);
 		$('#baseSalary2').textbox('setValue',row.dbasesalary.toFixed(2));
 		$('#baseRemark2').textbox('setValue',row.remark);

	}
	}
	function remove_xx(){
    		var row = $('#baseList').datagrid('getSelected');
			if (!row){
				$.messager.alert('友情提示','请选择信息','error');
			}else{
				$.messager.confirm('友情提示','将删除该信息，确定么？',function(r){   
				    if (r){   
				       $.post("${ctx}/salary/removeSalaryBase.action", {"id": row.id },
					   function(data){
					    if(data=="01"){  
							$.messager.alert('友情提示','删除成功','info'); 
							resetDG('#baseList');
						}else{
							$.messager.alert('友情提示','删除失败','error'); 
						}
					   });   
				    }   
				});
			
			}
    	}
  //分页查询
  function doQuery(){
  	var queryParams=$('#baseList').datagrid('options').queryParams;
  	queryParams.name=$('#nameSch').textbox('getValue');
  	queryParams.empid=$('#empIdSch').textbox('getValue');
  	queryParams.deptname=$('#deptNameSch').combotree('getValue');
  	//重置当前页数为1
  	resetDG('#baseList');

  } 
  
  function formatSalary(val,row,index){
  	return val.toFixed(2);
  }
  
    </script>  
        
  </head>
  
  <body>
 
<!-- 主窗口 -->  	 
    <table id="baseList" class="easyui-datagrid" data-options="fit:true,
    								rownumbers:true,
									singleSelect:true,
									striped:true,
									fitColumns:true,
									toolbar:'#tb',
									pagination:true,
									pageSize:20,
									pageList:[20,30,50,100],
									url:'${ctx}/salary/listSalaryBase.action'">
		<thead>
			<tr>
				<th data-options="field:'ck',checkbox:true"></th>
				<th data-options="field:'uid',hidden:true"></th>
				<th data-options="field:'empid',align:'center'" width="200"><strong>工号</strong></th>
				<th data-options="field:'dtruename',align:'center'" width="200"><strong>姓名</strong></th>
				<th data-options="field:'deptname',align:'center'" width="200"><strong>部门</strong></th>
				<th data-options="field:'dbasesalary',formatter:formatSalary,align:'center'" width="300"><strong>基本工资</strong></th>
				<th data-options="field:'remark',align:'center'" width="300"><strong>备注</strong></th>
				<th data-options="field:'id',hidden:true"></th>
			</tr>
		</thead>
		
	</table>
<!-- Datagrid工具栏 -->
<div id="tb">
	<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
	   <td class="toolDiv">  		
	  		<a href="javascript:void(0)" onclick="add_xx()" class="easyui-linkbutton" data-options="iconCls:'icon-user-add',plain:true">增加信息</a><span class="vline">|</span>
			<a href="javascript:void(0)" onclick="edit_xx()" class="easyui-linkbutton" data-options="iconCls:'icon-user-edit',plain:true">修改信息</a><span class="vline">|</span>
			<a href="javascript:void(0)" onclick="remove_xx()" class="easyui-linkbutton" data-options="iconCls:'icon-user-delete',plain:true">刪除信息</a><span class="vline">|</span>
		</td>
	</tr>
	<tr>
	   <td class="serchDiv">
			基本工资设置
			&nbsp;&nbsp;员工名称：<input id="nameSch" oninput="doQuery()" onpropertychange="doQuery()"  class="easyui-textbox" type="text">
			&nbsp;&nbsp;工号：<input id="empIdSch" oninput="doQuery()" onpropertychange="doQuery()"  class="easyui-textbox" type="text">
			&nbsp;&nbsp;部门名称：<input id="deptNameSch" class="easyui-combotree" value="" data-options="url:'${ctx}/json/listDept2.action',value:'0',valueField:'id'," style="width:155px" oninput="doQuery()" onpropertychange="doQuery()"/>
			&nbsp;&nbsp;<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" 
			onclick="doQuery()">查询</a>
		</td>
	</tr>
	</table>
</div>
<!--增加窗口-->
    <div id="baseAddWnd"  style="width: 310px; height: 220px; padding: 5px; background: #fafafa;display: none">
    	<form id="baseAddForm" method="post" action="${ctx }/salary/saveSalaryBase.action">
    			 <input id="baseuId" name="uid"  type="hidden"/>
                 <input id="baseempId" name="empid" type="hidden"/>
                <table cellpadding=3>
                	<tr>
                        <td><a href="#" class="hyperLink" onclick="chooseEmp()">员工</a></td>
                        <td><input id="baseName" name="dtruename" class="easyui-textbox"  data-options="required:true"   style="width:200px"/></td>
                    </tr>
                    <tr>
                        <td>基本工资</td>
                        <td><input id="baseSalary" name=dbasesalary class="easyui-textbox"  data-options="required:true" style="width:200px"/></td>
                    </tr>
                    <tr>
                        <td>备注</td>
                        <td>
                        	<input id="baseRemark" name="remark" class="easyui-textbox" data-options="multiline:true" style="width:200px;height:50px">
	                    </td>
					</tr>
                </table>
        </form>
    </div>
<!--修改窗口-->
    <div id="updateWnd"  style="width: 310px; height: 220px; padding: 5px; background: #fafafa;display: none">
    	<form id="updateFrom" method="post" action="${ctx }/salary/updateSalaryBase.action">
    			<input id="baseId2" name="id" type="hidden"/>
    			<input id="baseuId2" name="uid" type="hidden"/>
    			<input id="baseempId2" name="empid" type="hidden"/>
                <table cellpadding=3>
                	<tr>
                        <td>员工</td>
                        <td><input id="baseName2" name="dtruename" class="easyui-textbox"  data-options="required:true" readonly="readonly" style="width:200px"/></td>
                    </tr>
                    <tr>
                        <td>基本工资</td>
                        <td><input id="baseSalary2" name="dbasesalary" class="easyui-textbox"  data-options="required:true" style="width:200px"/></td>
                    </tr>
					  <tr>
                        <td>备注</td>
                        <td>
                        	<input id="baseRemark2" name="remark" class="easyui-textbox" data-options="multiline:true" style="width:200px;height:50px">
	                    </td>
					</tr>
                </table>
        </form>
    </div> 

	<!-- 选择员工详情-->
	<div id="empWnd" style="display: none; width: 800px; height: 400px; border:false;">
	</div>
  </body>
  
  <script type="text/javascript">
  	//选择员工信息
    function chooseEmp()
    {
		var empWnd = $("#empWnd");
		empWnd.show();
		empWnd.dialog({
	    	title:'员工信息',
	        modal:true,
	        top:30,
			href : '${ctx}/business/toShowEmp.action',
	        buttons: [{
	        	text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					var row = $('#empList').datagrid('getSelected');
					if (!row){
						$.messager.alert('友情提示','请选择员工','info');
					}else{
						$('#baseName').textbox('setValue',row.user.name);
						$('#baseuId').val(row.uid);
						$('#baseempId').val(row.user.empId);
					}
					$('#empWnd').dialog('close');
				
				}
	        },{
	        	text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#empWnd').dialog('close');
				} 
	        }]
	    });
    }
  </script>
</html>
